<template>
  <div id="conpon">
    <top-bar :title="title"></top-bar>
    <div class="exchangeconpon">
      <md-field>
        <md-input-item ref v-model="exchangeCode" placeholder="请输入优惠券进行兑换"></md-input-item>
      </md-field>
      <p class="rzBtn" @click="ExchangeBtn">兑换</p>
    </div>
  </div>
</template>
<script>
import '@/assets/svgs/yhq_next.svg';
import { Tabs, Icon, Dialog, InputItem, Field, Toast } from 'mand-mobile';
import TopBar from '@/components/TopBar';
import Loading from '@/components/loading';
import { decryptByDESModeEBC, encryptByDESModeEBC } from '@/common/encrypt';
import http from '@/common/http';
import Utils from '@/common/pakjUtils';
export default {
  components: {
    [Tabs.name]: Tabs,
    [Icon.name]: Icon,
    [TopBar.name]: TopBar,
    [Toast.name]: Toast,
    [Field.name]: Field,
    [InputItem.name]: InputItem
  },
  data() {
    return {
      title: '兑换优惠券',
      exchangeCode: ''
    };
  },
  methods: {
    ExchangeBtn() {
      if (!this.exchangeCode) {
        Toast({
          content: '请输入优惠券进行兑换',
          duration: 3000,
          hasMask: true
        });
        return false;
      }
      let params = {
        coupon_code: this.exchangeCode
      };
      Loading.show();
      http.post('pakj/coupon/getAcouponByCode', params).then(res => {
        Loading.hide();
        if (res.data.code === '000000') {
          Dialog.alert({
            title: '提示',
            content: '兑换成功',
            confirmText: '确定'
          });
        } else {
          Dialog.alert({
            title: '提示',
            content: res.data.msg,
            confirmText: '确定'
          });
        }
      });
    }
  }
};
</script>
<style lang="stylus" scoped>
p {
  display: block;
  margin-block-start: 0px;
  margin-block-end: 0px;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
}

#conpon {
  height: 100vh;
  background-color: color-primary-background;
}

.exchangeconpon {
  padding-top: 20px;
}

.rzBtn {
  height: 98px;
  line-height: 98px;
  font-size: 36px;
  text-align: center;
  background-color: #FF6917;
  color: #fff;
  margin: 140px 20px 0px 20px;
  border-radius: 7px;
}
</style>
